﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq.Expressions;
using System.Text.RegularExpressions;
using TCL.DB;
using TCL.EO;
using System.Text;
using System.Threading;
using System.IO;
using System.Security.Cryptography;
using Facebook;
using System.Net;
using System.Collections.Specialized;
using System.Web;

namespace TCL.FUNC
{
    public class OtherEx
    {

        public static HttpStatusCode getHttp_Status(String sUrl)
        {
            HttpWebResponse response;
            try
            {
                HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(sUrl);
                response = (HttpWebResponse)webRequest.GetResponse();
            }
            catch (WebException we)
            {
                response = (HttpWebResponse)we.Response;
            }
            if (response != null)
                return response.StatusCode;
            else
                return HttpStatusCode.BadRequest;
        }

        public static String Facebook_Graph_API_Get(FacebookClient FBClient, String sQuery)
        {
            String sRet = "";
            try
            {
                FacebookProxyEO.RequestEO _RequestEO = new FacebookProxyEO.RequestEO(FBClient, sQuery, ConstEx.Facebook_HttpMethod.Get);
                String strJson = Convert.ToBase64String(Encoding.UTF8.GetBytes(ConvertEx.JsonEx.Object_2_Json(_RequestEO)));
                if (SystemEx.getAppSettings("FacebookProxy_Used", "9").Equals("1"))
                {
                    using (MyWebClient client = new MyWebClient(Convert.ToInt32(SystemEx.getAppSettings("NMT_iRequestTimeout", "30"))))
                    {
                        if (SystemEx.getAppSettings("FacebookProxy_Proxy", "9").Equals("1"))
                        {
                            WebProxy proxy = new WebProxy("proxy.fis.vn", 8080);
                            proxy.Credentials = new NetworkCredential("fis\\ThangNM11", "AbCd@1234");
                            proxy.UseDefaultCredentials = false;
                            proxy.BypassProxyOnLocal = true;
                            client.Proxy = proxy;
                        }
                        //NameValueCollection lstParam = new NameValueCollection();
                        //lstParam["q"] = strJson;
                        client.QueryString.Add("q", strJson);
                        strJson = client.DownloadString(SystemEx.getAppSettings("FacebookProxy_Url"));
                        if (CheckEx.IsBase64String(strJson))
                        {
                            FacebookProxyEO.ResponseEO _ResponseEO = new FacebookProxyEO.ResponseEO();

                            strJson = Encoding.UTF8.GetString(Convert.FromBase64String(strJson));
                            _ResponseEO = ConvertEx.JsonEx.Json_2_Object<FacebookProxyEO.ResponseEO>(strJson, _ResponseEO.GetType());
                            if (_ResponseEO != null)
                            {
                                if (String.IsNullOrEmpty(_ResponseEO.Error))
                                    sRet = _ResponseEO.Content;
                                else
                                    throw new Exception(_ResponseEO.Error);
                            }
                        }
                    }
                }
                else
                    sRet = Convert.ToString(FBClient.Get(sQuery));
            }
            catch (Exception ex)
            {
                (new Logs()).WriteLog_To_DB(new TCL.EO.LogEO(ex.ToString() + "\n" + sQuery, ConstEx.Log_iType.EXCEPTION), false);
                if (SystemEx.getAppSettings("NMT_isDebug", "9").Equals("1"))
                    throw new Exception(ex.ToString());
            }
            return sRet;
        }

        public static Int64 Facebook_UserName_To_UserID(String sUserName)
        {
            Int64 iRet = 0;
            try
            {
                using (WebClient client = new WebClient())
                {
                    if (SystemEx.getAppSettings("FacebookProxy_Proxy", "9").Equals("1"))
                    {
                        WebProxy proxy = new WebProxy("proxy.fis.vn", 8080);
                        proxy.Credentials = new NetworkCredential("fis\\ThangNM11", "AbCd@1234");
                        proxy.UseDefaultCredentials = false;
                        proxy.BypassProxyOnLocal = true;
                        client.Proxy = proxy;
                    }
                    client.QueryString.Add("u", sUserName);
                    String htmlString = client.DownloadString(SystemEx.getAppSettings("FacebookProxy_Url"));
                    Int64.TryParse(htmlString, out iRet);
                }
            }
            catch (Exception ex)
            {
                (new Logs()).WriteLog_To_DB(new TCL.EO.LogEO(ex.ToString() + "\n" + sUserName, ConstEx.Log_iType.EXCEPTION), false);
                if (SystemEx.getAppSettings("NMT_isDebug", "9").Equals("1"))
                    throw new Exception(ex.ToString());
            }
            return iRet;
        }

        //public static SEOEO getDefaultSEO()
        //{
        //    SEOEO objRet = new SEOEO(1, 1, 1, 1);
        //    return objRet;
        //}

        public static String getShortUrl(String sCID, String sSID)
        {
            String sFormatUrl = "{0}/{1}";
            return String.Format(sFormatUrl, StringEx.ConvertToUnSign(sCID), StringEx.Trim(sSID)).ToLower();
        }

        public static String getRewriteUrl(String sCID, String sSID, String sTitle)
        {
            String sFormatUrl = "{0}/{1}-{2}";
            return String.Format(sFormatUrl, StringEx.ConvertToUnSign(sCID), StringEx.ConvertToUnSign(sTitle), StringEx.Trim(sSID)).ToLower();
        }

        public static void setRedirect(System.Web.UI.Page ctrlPage, String sUrlRewrite)
        {
            if (String.IsNullOrEmpty(sUrlRewrite))
            {
                ctrlPage.Response.Status = "301 Moved Permanently";
                ctrlPage.Response.AddHeader("Location", SystemEx.getAppSettings("HOMEPAGE") + "PageError.html?404=" + System.Web.HttpContext.Current.Server.UrlEncode(ctrlPage.Request.RawUrl));
            }
            else
            {
                ctrlPage.Response.Status = "301 Moved Permanently";
                ctrlPage.Response.AddHeader("Location", "../" + OtherEx.AddDomainInUrl(sUrlRewrite));
            }
        }

        public static String GetPropertyName<T>(Expression<Func<T>> propertyLambda)
        {
            var me = propertyLambda.Body as MemberExpression;
            if (me == null)
                return null;
            else
                return me.Member.Name;
        }

        public static String LoadMenu(Int32 _iAppID, Int32 _iParentID, Int32 _iLevel)
        {
            String result = String.Empty;
            List<FuncEO> lstTemp = (new ShareDAO.FuncDAO()).SelectBy_iAppID_iParentID(_iAppID, _iParentID);
            if (CheckEx.IsListObject(lstTemp))
            {
                if (_iLevel == 0)
                    result += "<ul id=\"tree_menu\">";
                else
                    result += "<ul>";
                foreach (FuncEO item in lstTemp)
                {
                    result += "<li><a href=\"" + OtherEx.AddDomainInUrl("access.aspx") + "?r=" + System.Web.HttpContext.Current.Server.UrlEncode(SecurityEx.Login.Encrypt(item.PK_iFunctionID.ToString(), SystemEx.getAppSettings("PRIVATE_KEY"))) + "\">" + item.sName + "</a>";
                    result += LoadMenu(_iAppID, item.PK_iFunctionID, _iLevel + 1);
                    result += "</li>";
                }
                result += "</ul>";
            }
            return result;
        }

        public static String RemoveDomainInUrl(String sUrl)
        {
            sUrl = StringEx.Trim(sUrl).ToLower();
            if (String.IsNullOrEmpty(sUrl))
                return sUrl;
            sUrl = sUrl.Replace("https://", "http://");
            sUrl = sUrl.Replace("ftp://", "http://");
            sUrl = sUrl.Replace("http://nguyenmanhthang.net/", "");
            sUrl = sUrl.Replace("http://www.nguyenmanhthang.net/", "");
            sUrl = sUrl.Replace("http://nguyenmanhthang.net", "");
            sUrl = sUrl.Replace("http://www.nguyenmanhthang.net", "");
            sUrl = sUrl.Replace("www.nguyenmanhthang.net/", "");
            sUrl = sUrl.Replace("www.nguyenmanhthang.net", "");
            sUrl = sUrl.Replace("nguyenmanhthang.net/", "");
            sUrl = sUrl.Replace("nguyenmanhthang.net", "");
            if (sUrl.Length <= 1)
                return sUrl;
            if (sUrl.Substring(0, 1).Equals("/"))
                sUrl = sUrl.Substring(1);
            return sUrl;
        }

        public static String AddDomainInUrl(String sUrl)
        {
            if (StringEx.Compare(sUrl, "nguyenmanhthang.net"))
            {
                return StringEx.Trim(sUrl).ToLower();
            }
            sUrl = StringEx.Trim(sUrl).ToLower();
            if (sUrl.Length < 1)
                return sUrl;
            if (sUrl.Substring(0, 1).Equals("/"))
                sUrl = sUrl.Substring(1);
            sUrl = SystemEx.getAppSettings("HOMEPAGE") + sUrl;
            return sUrl;
        }

        public static String getUrlStandard(String strUrl)
        {
            if (StringEx.Compare(strUrl, "http://") || StringEx.Compare(strUrl, "https://") || StringEx.Compare(strUrl, "ftp://"))
                return StringEx.Trim(strUrl);
            else
                return StringEx.Trim("http://" + strUrl);
        }

        public static String setMaxLength(String sInput, Int32 iMaxLength)
        {
            sInput = StringEx.Trim(sInput);
            return StringEx.Trim(sInput.PadRight(iMaxLength).Substring(0, iMaxLength));
        }

        public static String Minify_CSS(String body)
        {
            body = Regex.Replace(body, @"[a-zA-Z]+#", "#");
            body = Regex.Replace(body, @"[\n\r]+\s*", String.Empty);
            body = Regex.Replace(body, @"\s+", " ");
            body = Regex.Replace(body, @"\s?([:,;{}])\s?", "$1");
            body = body.Replace(";}", "}");
            body = Regex.Replace(body, @"([\s:]0)(px|pt|%|em)", "$1");

            // Remove comments from CSS
            body = Regex.Replace(body, @"/\*[\d\D]*?\*/", String.Empty);

            return body;
        }

        public static String getDayOfWeek(DateTime dt)
        {
            String sRet = "";
            switch (dt.DayOfWeek)
            {
                case DayOfWeek.Monday:
                    sRet = "THỨ HAI";
                    break;
                case DayOfWeek.Tuesday:
                    sRet = "THỨ BA";
                    break;
                case DayOfWeek.Wednesday:
                    sRet = "THỨ TƯ";
                    break;
                case DayOfWeek.Thursday:
                    sRet = "THỨ NĂM";
                    break;
                case DayOfWeek.Friday:
                    sRet = "THỨ SÁU";
                    break;
                case DayOfWeek.Saturday:
                    sRet = "THỨ BẢY";
                    break;
                case DayOfWeek.Sunday:
                    sRet = "CHỦ NHẬT";
                    break;
            }
            return sRet;
        }

        public static String getInfoRequest(Int16 iType)
        {
            if (System.Web.HttpContext.Current == null)
                return "NULL";
            else if (System.Web.HttpContext.Current.Request == null)
                return "NULL";

            switch (iType)
            {
                case 1: // Url
                    return OtherEx.RemoveDomainInUrl(System.Web.HttpContext.Current.Request.RawUrl);
                    break;
                case 2: // UrlRef
                    if (System.Web.HttpContext.Current.Request.UrlReferrer == null)
                        return "NULL";
                    else
                        return OtherEx.RemoveDomainInUrl(System.Web.HttpContext.Current.Request.UrlReferrer.AbsoluteUri);
                    break;
                case 3: // Original
                    if (System.Web.HttpContext.Current.Request.UrlReferrer == null)
                        return "NULL";
                    else
                        return OtherEx.RemoveDomainInUrl(System.Web.HttpContext.Current.Request.UrlReferrer.OriginalString);
                    break;
                case 4: // IP
                    return System.Web.HttpContext.Current.Request.UserHostAddress;
                    break;
                default:
                    return "NULL";
                    break;
            }
        }

        public static List<int> Get_List_ID_by_List_Index(List<int> lstIndex, DataSet ListID)
        {
            List<int> lst = new List<int>();
            int tmp;
            for (int i = 0; i < lstIndex.Count; i++)
            {
                tmp = Convert.ToInt32(ListID.Tables[0].Rows[lstIndex[i]]["PK_lCauhoi_ID"].ToString());
                lst.Add(tmp);
            }
            return lst;
        }

        public static List<int> Random_Array_Not_Duplicate(int sum, int num)
        {
            int tmp;
            List<int> lst = new List<int>();
            do
            {
                tmp = Random_Number(0, sum);
                if (lst.Contains(tmp) == false)
                {
                    lst.Add(tmp);
                }
            }
            while (lst.Count < num);
            return lst;
        }

        public static int Random_Number(int min, int max)
        {
            Random random = new Random();
            int id = random.Next(min, max);
            random = null;
            return id;
        }

        private static string[] ChuSo = new string[10] { " không", " một", " hai", " ba", " bốn", " năm", " sáu", " bẩy", " tám", " chín" };
        private static string[] Tien = new string[6] { "", " nghìn", " triệu", " tỷ", " nghìn tỷ", " triệu tỷ" };

        // Hàm đọc số thành chữ
        public static string DocTienBangChu(long SoTien, string strTail)
        {
            int lan, i;
            long so;
            string KetQua = "", tmp = "";
            int[] ViTri = new int[6];
            if (SoTien < 0) return "Số tiền âm !";
            if (SoTien == 0) return "Không đồng !";
            if (SoTien > 0)
            {
                so = SoTien;
            }
            else
            {
                so = -SoTien;
            }
            //Kiểm tra số quá lớn
            if (SoTien > 8999999999999999)
            {
                SoTien = 0;
                return "";
            }
            ViTri[5] = (int)(so / 1000000000000000);
            so = so - long.Parse(ViTri[5].ToString()) * 1000000000000000;
            ViTri[4] = (int)(so / 1000000000000);
            so = so - long.Parse(ViTri[4].ToString()) * +1000000000000;
            ViTri[3] = (int)(so / 1000000000);
            so = so - long.Parse(ViTri[3].ToString()) * 1000000000;
            ViTri[2] = (int)(so / 1000000);
            ViTri[1] = (int)((so % 1000000) / 1000);
            ViTri[0] = (int)(so % 1000);
            if (ViTri[5] > 0)
            {
                lan = 5;
            }
            else if (ViTri[4] > 0)
            {
                lan = 4;
            }
            else if (ViTri[3] > 0)
            {
                lan = 3;
            }
            else if (ViTri[2] > 0)
            {
                lan = 2;
            }
            else if (ViTri[1] > 0)
            {
                lan = 1;
            }
            else
            {
                lan = 0;
            }
            for (i = lan; i >= 0; i--)
            {
                tmp = DocSo3ChuSo(ViTri[i]);
                KetQua += tmp;
                if (ViTri[i] != 0) KetQua += Tien[i];
                if ((i > 0) && (!string.IsNullOrEmpty(tmp))) KetQua += ",";//&& (!string.IsNullOrEmpty(tmp))
            }
            if (KetQua.Substring(KetQua.Length - 1, 1) == ",") KetQua = KetQua.Substring(0, KetQua.Length - 1);
            KetQua = KetQua.Trim() + strTail;
            return KetQua.Substring(0, 1).ToUpper() + KetQua.Substring(1);
        }

        // Hàm đọc số có 3 chữ số
        private static string DocSo3ChuSo(int baso)
        {
            int tram, chuc, donvi;
            string KetQua = "";
            tram = (int)(baso / 100);
            chuc = (int)((baso % 100) / 10);
            donvi = baso % 10;
            if ((tram == 0) && (chuc == 0) && (donvi == 0)) return "";
            if (tram != 0)
            {
                KetQua += ChuSo[tram] + " trăm";
                if ((chuc == 0) && (donvi != 0)) KetQua += " linh";
            }
            if ((chuc != 0) && (chuc != 1))
            {
                KetQua += ChuSo[chuc] + " mươi";
                if ((chuc == 0) && (donvi != 0)) KetQua = KetQua + " linh";
            }
            if (chuc == 1) KetQua += " mười";
            switch (donvi)
            {
                case 1:
                    if ((chuc != 0) && (chuc != 1))
                    {
                        KetQua += " mốt";
                    }
                    else
                    {
                        KetQua += ChuSo[donvi];
                    }
                    break;
                case 5:
                    if (chuc == 0)
                    {
                        KetQua += ChuSo[donvi];
                    }
                    else
                    {
                        KetQua += " lăm";
                    }
                    break;
                default:
                    if (donvi != 0)
                    {
                        KetQua += ChuSo[donvi];
                    }
                    break;
            }
            return KetQua;
        }



        public static KeyValueEO getKeyFromIdentityNumber(KeyValueEO objInput, Int16 iType = 0)
        {
            if (!String.IsNullOrEmpty(objInput.K))
            {
                objInput.K = iType.ToString() + objInput.K.PadLeft(12, '0');
            }
            objInput = ConvertNumberToChar(objInput, iType);
            objInput.K = Convert.ToString(Convert.ToInt64(objInput.K.Substring(1)));
            return objInput;
        }


        public static KeyValueEO ConvertNumberToChar(KeyValueEO objInput, Int16 iType = 0)
        {
            KeyValueEO objRet = new KeyValueEO();
            try
            {
                // ========= Begin Init ===================================
                String sType = Convert.ToString(iType);
                StringBuilder sbTemp;
                Char chTemp;
                Char[] arrChar;
                List<KeyValueNumEO> lstChange = new List<KeyValueNumEO>();
                lstChange.Add(new KeyValueNumEO(0, 3));
                lstChange.Add(new KeyValueNumEO(1, 6));
                lstChange.Add(new KeyValueNumEO(2, 5));
                lstChange.Add(new KeyValueNumEO(4, 7));
                String strDic = "_0123456789-abcdefghijklmnopqrstuvwxyz";
                List<Char> lstDic = new List<char>();
                lstDic.AddRange(strDic);
                // ========= End Init ===================================

                if (iType > 0 && iType < 10 && (objInput == null || (String.IsNullOrEmpty(objInput.K) && String.IsNullOrEmpty(objInput.V))))   //Lấy bộ key mới
                {
                    Random rd = new Random();
                    Thread.Sleep(rd.Next(1992, 3090));
                    objInput = new KeyValueEO(DateTime.Now.ToString("yyMMddHHmmss"), null);
                    objInput.K = sType.PadLeft(1, '0') + objInput.K;
                    objRet = objInput;
                }

                if (String.IsNullOrEmpty(objInput.K) && !String.IsNullOrEmpty(objInput.V))  //Chuyển từ sKey -> iKey
                {
                    sType = objInput.V.Substring(0, 1);
                    objInput.V = objInput.V.Substring(1);
                    objRet.V = objInput.V;
                    sbTemp = new StringBuilder(objInput.V);
                    foreach (var item in lstChange)
                    {
                        chTemp = sbTemp[item.K];
                        sbTemp[item.K] = sbTemp[item.V];
                        sbTemp[item.V] = chTemp;
                    }
                    objInput.V = sbTemp.ToString();
                    arrChar = objInput.V.ToCharArray();
                    for (Int16 i = 0; i < arrChar.Length; i++)
                    {
                        if (i <= 3)
                            objRet.K += Convert.ToString(lstDic.IndexOf(arrChar[i])).PadLeft(2, '0');
                        else
                            objRet.K += Convert.ToString(arrChar[i]);
                    }
                }
                else if (!String.IsNullOrEmpty(objInput.K) && String.IsNullOrEmpty(objInput.V)) //Chuyển từ iKey -> sKey
                {
                    sType = objInput.K.Substring(0, 1);
                    objInput.K = objInput.K.Substring(1);
                    objRet.K = objInput.K;
                    for (Int16 i = 0; i < 12; i += 2)
                    {
                        if (i >= 8)
                            objRet.V += objInput.K.Substring(i, 2);
                        else
                            objRet.V += Convert.ToString(lstDic[Convert.ToInt16(objInput.K.Substring(i, 2))]);
                    }

                    sbTemp = new StringBuilder(objRet.V);
                    foreach (var item in lstChange)
                    {
                        chTemp = sbTemp[item.K];
                        sbTemp[item.K] = sbTemp[item.V];
                        sbTemp[item.V] = chTemp;
                    }
                    objRet.V = sbTemp.ToString();
                }
                objRet.K = sType + objRet.K;
                objRet.V = sType + objRet.V;
            }
            catch
            {
            }
            return objRet;
        }



        //public static String ConvertInt64ToStringBase64(Int64 iInput)
        //{
        //    String sRet = "";
        //    Byte[] data = new Byte[12];
        //    data = BitConverter.GetBytes(iInput);
        //    sRet = Convert.ToBase64String(data, 0, 5).Substring(0, 7);
        //    return sRet;
        //}

        //public static Int64 ConvertStringBase64ToInt64(String sInput)
        //{
        //    Int64 iRet = 0;
        //    Byte[] data = new Byte[12];
        //    Convert.FromBase64String(sInput + "=").CopyTo(data, 0);
        //    iRet = BitConverter.ToInt64(data, 0);
        //    return iRet;
        //}

        //public static KeyValueEO getIDEx(Int16 iPrefix, String sKey = null)
        //{
        //    KeyValueEO objRet;
        //    String sValue;
        //    if (String.IsNullOrEmpty(sKey))
        //    {
        //        do
        //        {
        //            sKey = DateTime.Now.ToString("yyMMddHHmmss").Substring(1);
        //            sKey = iPrefix.ToString() + sKey;
        //            sValue = ConvertInt64ToStringBase64(Convert.ToInt64(sKey));
        //        } while (!StringEx.Equals(sKey, ConvertStringBase64ToInt64(sValue).ToString()));

        //    }
        //    else
        //    {
        //        sValue = ConvertStringBase64ToInt64(sKey).ToString();
        //    }
        //    objRet = new KeyValueEO(sKey, sValue);
        //    return objRet;
        //}

        public static String getHttp_ContentType(Int16 iType)
        {
            String sRet = "";
            switch (iType)
            {
                case 10: sRet = "text/plain"; break;    //  xdr, vcs, txt, map, h, cpp, cnf, c, bas, asm
                case 11: sRet = "text/xml"; break;      //  xslt, xsl, xsf, xsd, xml, wsdl, vml, mno, exe.config, dtd, dll.config, disco
                case 12: sRet = "text/html"; break;     //  hxt, html, htm
                case 13: sRet = ""; break;           //
                case 14: sRet = ""; break;           //
                case 15: sRet = ""; break;           //
                case 16: sRet = ""; break;           //
                case 17: sRet = ""; break;           //
                case 18: sRet = ""; break;           //
                case 19: sRet = ""; break;           //

                case 20: sRet = "image/png"; break;     //  png, pnz
                case 21: sRet = "image/jpeg"; break;    //  jpg, jpeg, jpe, 
                case 22: sRet = "image/gif"; break;     //  gif
                case 23: sRet = "image/bmp"; break;     //  bmp, dib
                case 24: sRet = "image/pjpeg"; break;   //  jfif
                case 25: sRet = "image/tiff"; break;    //  tiff, tif
                case 26: sRet = ""; break;           //
                case 27: sRet = ""; break;           //
                case 28: sRet = ""; break;           //
                case 29: sRet = ""; break;           //

                case 30: sRet = "video/mpeg"; break;    //  mpv2, mpg, mpeg, mpe, mpa, mp2, m1v
                case 31: sRet = ""; break;           //
                case 32: sRet = ""; break;           //
                case 33: sRet = ""; break;           //
                case 34: sRet = ""; break;           //
                case 35: sRet = ""; break;           //
                case 36: sRet = ""; break;           //
                case 37: sRet = ""; break;           //
                case 38: sRet = ""; break;           //
                case 39: sRet = ""; break;           //

                case 40: sRet = "application/msword"; break;                    //  doc, dot
                case 41: sRet = "application/vnd.ms-word.document.12"; break;   //  docx
                case 42: sRet = "application/vnd.ms-excel"; break;              //  xla, xlc, xlm, xls, xlt, xlw
                case 43: sRet = "application/vnd.ms-excel.12"; break;           //  xlsx
                case 44: sRet = ""; break;           //
                case 45: sRet = ""; break;           //
                case 46: sRet = ""; break;           //
                case 47: sRet = ""; break;           //
                case 48: sRet = ""; break;           //
                case 49: sRet = ""; break;           //

                case 50: sRet = ""; break;           //
                case 51: sRet = ""; break;           //
                case 52: sRet = ""; break;           //
                case 53: sRet = ""; break;           //
                case 54: sRet = ""; break;           //
                case 55: sRet = ""; break;           //
                case 56: sRet = ""; break;           //
                case 57: sRet = ""; break;           //
                case 58: sRet = ""; break;           //
                case 59: sRet = ""; break;           //

                case 60: sRet = ""; break;           //
                case 61: sRet = ""; break;           //
                case 62: sRet = ""; break;           //
                case 63: sRet = ""; break;           //
                case 64: sRet = ""; break;           //
                case 65: sRet = ""; break;           //
                case 66: sRet = ""; break;           //
                case 67: sRet = ""; break;           //
                case 68: sRet = ""; break;           //
                case 69: sRet = ""; break;           //

                case 70: sRet = ""; break;           //
                case 71: sRet = ""; break;           //
                case 72: sRet = ""; break;           //
                case 73: sRet = ""; break;           //
                case 74: sRet = ""; break;           //
                case 75: sRet = ""; break;           //
                case 76: sRet = ""; break;           //
                case 77: sRet = ""; break;           //
                case 78: sRet = ""; break;           //
                case 79: sRet = ""; break;           //

                case 80: sRet = ""; break;           //
                case 81: sRet = ""; break;           //
                case 82: sRet = ""; break;           //
                case 83: sRet = ""; break;           //
                case 84: sRet = ""; break;           //
                case 85: sRet = ""; break;           //
                case 86: sRet = ""; break;           //
                case 87: sRet = ""; break;           //
                case 88: sRet = ""; break;           //
                case 89: sRet = ""; break;           //

                case 90: sRet = ""; break;           //
                case 91: sRet = ""; break;           //
                case 92: sRet = ""; break;           //
                case 93: sRet = ""; break;           //
                case 94: sRet = ""; break;           //
                case 95: sRet = ""; break;           //
                case 96: sRet = ""; break;           //
                case 97: sRet = ""; break;           //
                case 98: sRet = ""; break;           //
                case 99: sRet = ""; break;           //

                default: break;
            }
            return sRet;
        }

        public static Boolean CheckSum(String sCheckSum, String sFilePath)
        {
            Boolean bRet = false;
            try
            {
                byte[] byteToCalculate = Folder_File.ReadAllBytes(sFilePath);
                int checksum = 0;
                foreach (byte chData in byteToCalculate)
                {
                    checksum += chData;
                }
                checksum &= 0xff;
                if (StringEx.Equals(checksum.ToString("X2"), sCheckSum))
                    bRet = true;
            }
            catch
            {
            }
            return bRet;
        }

        public static Boolean Md5CheckSum(String sMd5CheckSum, String sFilePath)
        {
            Boolean bRet = false;
            try
            {
                String strTemp;
                if (File.Exists(sFilePath))
                {
                    using (var md5 = MD5.Create())
                    {
                        using (var stream = File.OpenRead(sFilePath))
                        {
                            strTemp = BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", String.Empty);
                        }
                    }
                    if (StringEx.Equals(strTemp, sMd5CheckSum))
                        bRet = true;
                }
            }
            catch
            {
            }
            return bRet;
        }
    }
}
